{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "本例子是 v1.0 的基金净值预测引擎，现在已经升级的 v3.0，不需要在参考该 notebook 的代码，请直接使用 ``xa.QDIIPredict`` 类即可，\n",
    "各种情况都已做了妥善的封装和考虑"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import xalpha as xa\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 南方原油持仓及基准\n",
    "# 38335 WisdomTree WTI Crude Oil\n",
    "# 44793 United States 12 Month Oil Fund LP\n",
    "# 995771 UBS ETF CHCMCI Oil SF USD A-dis https://cn.investing.com/etfs/ubs-cmci-oil-sf-usd\n",
    "# 44794 United States Oil Fund LP\n",
    "# 44792 Invesco DB Oil Fund\n",
    "# 38324 WisdomTree Brent Crude Oil\n",
    "# 44634 United States Brent Oil Fund LP\n",
    "# 37450 WisdomTree Brent Crude Oil 1mth\n",
    "# 1014132 iPath S&P GSCI Crude Oil Total Return Index ETN\n",
    "\n",
    "# 8833 brent oil\n",
    "# 8849 wti oil\n",
    "\n",
    "# 2019 第四季度季报披露\n",
    "# reference: http://pdf.dfcfw.com/pdf/H2_AN202001191374337197_1.pdf\n",
    "holdings_501018_19s3 = {\n",
    "    \"37450\": 15.31,\n",
    "    \"44792\": 13.64,\n",
    "    \"44794\": 13.46,\n",
    "    \"44634\": 12.48,\n",
    "    \"38335\": 11.73,\n",
    "    \"38324\": 9.45,\n",
    "    \"995771\": 6.53,\n",
    "    \"44793\": 6.02,\n",
    "    \"1014132\": 5.42,\n",
    "}\n",
    "# 2019 第三季度季报披露\n",
    "# reference: http://pdf.dfcfw.com/pdf/H2_AN201910241369695857_1.pdf\n",
    "holdings_501018_19s4 = {\n",
    "    \"38335\": 7.34,\n",
    "    \"44793\": 8.14,\n",
    "    \"995771\": 8.68,\n",
    "    \"44794\": 9.63,\n",
    "    \"44792\": 11.6,\n",
    "    \"38324\": 15.04,\n",
    "    \"44634\": 15.42,\n",
    "    \"37450\": 17.51,\n",
    "    \"1014132\": 0.06,\n",
    "}\n",
    "holdings_501018_bc_cash = {\"8849\": 52.8, \"8833\": 35.2}\n",
    "# holdings_bc = {\"8849\": 60, \"8833\": 40}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 国泰商品相关基金持仓\n",
    "# 14218 PROSHARES ULTRA BLOOMBERG CRUDE OIL\n",
    "# 37471 Invesco DB US Dollar Index Bullish Fund (UUP)\n",
    "## 44792 Invesco DB Oil Fund (DBO)\n",
    "# 44798 VELOCITYSHARES 3X LONG CRUDE OIL ETN\n",
    "# 44718 INVESCO DB PRECIOUS METALS FUND\n",
    "# 9236 ISHARES SILVER TRUST (SLV)\n",
    "\n",
    "holdings_160216_19s4 = {\n",
    "    \"44794\": 16.9,\n",
    "    \"14218\": 14.03,\n",
    "    \"44634\": 11.77,\n",
    "    \"37471\": 10.98,\n",
    "    \"44792\": 9.1,\n",
    "    \"44798\": 7.82,\n",
    "    \"1014132\": 7.76,\n",
    "    \"44793\": 2.25,\n",
    "    \"44718\": 0.01,\n",
    "    \"9236\": 0,\n",
    "}\n",
    "# reference: http://pdf.dfcfw.com/pdf/H2_AN202001161374256079_1.pdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 华宝油气\n",
    "#  38284 SPDR® S&P Oil & Gas Exploration & Production ETF (XOP)\n",
    "#  1010825 S&P Oil & Gas Exploration & Production Select Industry TR (SPSIOPTR)\n",
    "# 华宝油气直接持仓 SPSIOPTR 成分股，而非买入 XOP，直接用油气指数模拟持仓\n",
    "holdings_162411_19s4 = {\"1010825\": 90}\n",
    "# reference: http://pdf.dfcfw.com/pdf/H2_AN202001201374387272_1.pdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cache_data(data, *args, start=\"20180101\"):\n",
    "    for arg in args:\n",
    "        for k in arg:\n",
    "            if k not in data:\n",
    "                data[k] = xa.get_daily(k, start=start)\n",
    "\n",
    "\n",
    "def daily_increment(code, date, lastday=None, _default=None):\n",
    "    if not _default:\n",
    "        tds = xa.get_daily(code=code, end=date, prev=15)\n",
    "        tds = tds[tds[\"date\"] <= date]\n",
    "        if not lastday:\n",
    "            ratio = tds.iloc[-1][\"close\"] / tds.iloc[-2][\"close\"]\n",
    "        else:\n",
    "            tds2 = tds[tds[\"date\"] <= lastday]\n",
    "            ratio = tds.iloc[-1][\"close\"] / tds2.iloc[-1][\"close\"]\n",
    "        return ratio\n",
    "    # _default table dict is existing\n",
    "    tds = _default[code][_default[code][\"date\"] <= date]\n",
    "    if not lastday:\n",
    "        ratio = tds.iloc[-1][\"close\"] / tds.iloc[-2][\"close\"]\n",
    "    else:\n",
    "        tds2 = tds[tds[\"date\"] <= lastday]\n",
    "        ratio = tds.iloc[-1][\"close\"] / tds2.iloc[-1][\"close\"]\n",
    "    return ratio\n",
    "\n",
    "\n",
    "def evaluate_fluctuation(holding_dict, date, lastday=None, _default=None, _usd=\"\"):\n",
    "    price = 0\n",
    "    tot = 0\n",
    "    for k, v in holding_dict.items():\n",
    "        tot += v\n",
    "    remain = 100 - tot\n",
    "    for fundid, percent in holding_dict.items():\n",
    "        ratio = daily_increment(fundid, date, lastday, _default=_default)\n",
    "        #         print(fundid, ratio)\n",
    "        price += ratio * percent / 100\n",
    "    price += remain / 100  # currency part\n",
    "    if _usd:  # 美元资产需换算汇率, 中间价数据似乎精确度好于市场数据 2111\n",
    "        price = price * daily_increment(_usd, date, lastday, _default=_default)\n",
    "    return (price - 1) * 100\n",
    "\n",
    "\n",
    "def estimate_table(start, end, *cols, _default=None):\n",
    "    \"\"\"\n",
    "\n",
    "    :param cols: Tuple[str, str, Dict]. (colname, _usd, holding_dict).\n",
    "    \"\"\"\n",
    "    compare_data = {\n",
    "        \"date\": [],\n",
    "    }\n",
    "    for col in cols:\n",
    "        compare_data[col[0]] = []\n",
    "    dl = pd.Series(pd.date_range(start=start, end=end))\n",
    "    dl = dl[dl.isin(xa.cons.opendate)]\n",
    "    for i, d in enumerate(dl):\n",
    "        if i == 0:\n",
    "            continue\n",
    "\n",
    "        dstr = d.strftime(\"%Y%m%d\")\n",
    "        lstdstr = dl.iloc[i - 1].strftime(\"%Y%m%d\")\n",
    "        compare_data[\"date\"].append(d)\n",
    "        for col in cols:\n",
    "            compare_data[col[0]].append(\n",
    "                evaluate_fluctuation(\n",
    "                    col[2], dstr, lstdstr, _default=_default, _usd=col[1]\n",
    "                )\n",
    "            )\n",
    "    cpdf = pd.DataFrame(compare_data)\n",
    "    col0 = cols[0]\n",
    "    for col in cols[1:]:\n",
    "        cpdf[\"diff_\" + col0[0] + \"_\" + col[0]] = cpdf[col0[0]] - cpdf[col[0]]\n",
    "    return cpdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "cache_table = {}\n",
    "cache_data(\n",
    "    cache_table,\n",
    "    holdings_160216_19s4,\n",
    "    holdings_162411_19s4,\n",
    "    holdings_501018_19s3,\n",
    "    holdings_501018_19s4,\n",
    "    holdings_501018_bc_cash,\n",
    "    [\"F501018\", \"USD/CNY\", \"2111\", \"F160216\", \"F162411\"],\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 南方原油净值预估"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "nfyydf = estimate_table(\n",
    "    \"20190101\",\n",
    "    \"20200305\",\n",
    "    (\"real\", \"\", {\"F501018\": 100}),\n",
    "    (\"fund_est\", \"USD/CNY\", holdings_501018_19s4),\n",
    "    (\"fund_est_2111\", \"2111\", holdings_501018_19s4),\n",
    "    (\"bc_est\", \"USD/CNY\", holdings_501018_bc_cash),\n",
    "    (\"bc_est_2111\", \"2111\", holdings_501018_bc_cash),\n",
    "    _default=cache_table,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>real</th>\n",
       "      <th>fund_est</th>\n",
       "      <th>fund_est_2111</th>\n",
       "      <th>bc_est</th>\n",
       "      <th>bc_est_2111</th>\n",
       "      <th>diff_real_fund_est</th>\n",
       "      <th>diff_real_fund_est_2111</th>\n",
       "      <th>diff_real_bc_est</th>\n",
       "      <th>diff_real_bc_est_2111</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>263</th>\n",
       "      <td>2020-02-07</td>\n",
       "      <td>-0.647948</td>\n",
       "      <td>-0.785591</td>\n",
       "      <td>-0.037261</td>\n",
       "      <td>-1.254779</td>\n",
       "      <td>-0.509988</td>\n",
       "      <td>0.137642</td>\n",
       "      <td>-0.610687</td>\n",
       "      <td>0.606830</td>\n",
       "      <td>-0.137960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>264</th>\n",
       "      <td>2020-02-10</td>\n",
       "      <td>-1.096838</td>\n",
       "      <td>-1.426025</td>\n",
       "      <td>-1.800490</td>\n",
       "      <td>-1.428398</td>\n",
       "      <td>-1.802854</td>\n",
       "      <td>0.329187</td>\n",
       "      <td>0.703652</td>\n",
       "      <td>0.331560</td>\n",
       "      <td>0.706016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>265</th>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>0.429613</td>\n",
       "      <td>0.624201</td>\n",
       "      <td>0.310294</td>\n",
       "      <td>0.932186</td>\n",
       "      <td>0.617319</td>\n",
       "      <td>-0.194587</td>\n",
       "      <td>0.119319</td>\n",
       "      <td>-0.502573</td>\n",
       "      <td>-0.187706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>1.571827</td>\n",
       "      <td>2.244064</td>\n",
       "      <td>2.593395</td>\n",
       "      <td>2.198130</td>\n",
       "      <td>2.547303</td>\n",
       "      <td>-0.672238</td>\n",
       "      <td>-1.021568</td>\n",
       "      <td>-0.626303</td>\n",
       "      <td>-0.975477</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>0.333007</td>\n",
       "      <td>0.504982</td>\n",
       "      <td>0.481938</td>\n",
       "      <td>0.701662</td>\n",
       "      <td>0.678573</td>\n",
       "      <td>-0.171975</td>\n",
       "      <td>-0.148931</td>\n",
       "      <td>-0.368655</td>\n",
       "      <td>-0.345566</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>0.829754</td>\n",
       "      <td>1.198974</td>\n",
       "      <td>1.258412</td>\n",
       "      <td>1.343349</td>\n",
       "      <td>1.402872</td>\n",
       "      <td>-0.369220</td>\n",
       "      <td>-0.428658</td>\n",
       "      <td>-0.513595</td>\n",
       "      <td>-0.573118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>0.116178</td>\n",
       "      <td>-0.021618</td>\n",
       "      <td>-0.033048</td>\n",
       "      <td>0.298117</td>\n",
       "      <td>0.286651</td>\n",
       "      <td>0.137796</td>\n",
       "      <td>0.149225</td>\n",
       "      <td>-0.181939</td>\n",
       "      <td>-0.170473</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>2020-02-18</td>\n",
       "      <td>-0.232086</td>\n",
       "      <td>-0.002015</td>\n",
       "      <td>0.181235</td>\n",
       "      <td>-0.058525</td>\n",
       "      <td>0.124622</td>\n",
       "      <td>-0.230071</td>\n",
       "      <td>-0.413321</td>\n",
       "      <td>-0.173561</td>\n",
       "      <td>-0.356708</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>271</th>\n",
       "      <td>2020-02-19</td>\n",
       "      <td>2.268101</td>\n",
       "      <td>2.533318</td>\n",
       "      <td>2.275533</td>\n",
       "      <td>2.364867</td>\n",
       "      <td>2.107506</td>\n",
       "      <td>-0.265216</td>\n",
       "      <td>-0.007432</td>\n",
       "      <td>-0.096765</td>\n",
       "      <td>0.160596</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>272</th>\n",
       "      <td>2020-02-20</td>\n",
       "      <td>0.710833</td>\n",
       "      <td>0.478790</td>\n",
       "      <td>0.813269</td>\n",
       "      <td>0.618737</td>\n",
       "      <td>0.953681</td>\n",
       "      <td>0.232043</td>\n",
       "      <td>-0.102436</td>\n",
       "      <td>0.092097</td>\n",
       "      <td>-0.242848</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>273</th>\n",
       "      <td>2020-02-21</td>\n",
       "      <td>-1.138716</td>\n",
       "      <td>-1.355870</td>\n",
       "      <td>-1.555549</td>\n",
       "      <td>-0.612975</td>\n",
       "      <td>-0.814157</td>\n",
       "      <td>0.217154</td>\n",
       "      <td>0.416833</td>\n",
       "      <td>-0.525741</td>\n",
       "      <td>-0.324559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>274</th>\n",
       "      <td>2020-02-24</td>\n",
       "      <td>-2.760590</td>\n",
       "      <td>-3.476302</td>\n",
       "      <td>-3.494192</td>\n",
       "      <td>-3.202966</td>\n",
       "      <td>-3.220907</td>\n",
       "      <td>0.715711</td>\n",
       "      <td>0.733602</td>\n",
       "      <td>0.442376</td>\n",
       "      <td>0.460317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>275</th>\n",
       "      <td>2020-02-25</td>\n",
       "      <td>-2.085169</td>\n",
       "      <td>-1.550823</td>\n",
       "      <td>-1.753927</td>\n",
       "      <td>-2.434255</td>\n",
       "      <td>-2.635537</td>\n",
       "      <td>-0.534346</td>\n",
       "      <td>-0.331241</td>\n",
       "      <td>0.349086</td>\n",
       "      <td>0.550368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>2020-02-26</td>\n",
       "      <td>-1.759648</td>\n",
       "      <td>-1.753248</td>\n",
       "      <td>-1.478477</td>\n",
       "      <td>-2.359271</td>\n",
       "      <td>-2.086195</td>\n",
       "      <td>-0.006400</td>\n",
       "      <td>-0.281171</td>\n",
       "      <td>0.599623</td>\n",
       "      <td>0.326547</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>277</th>\n",
       "      <td>2020-02-27</td>\n",
       "      <td>-4.152249</td>\n",
       "      <td>-3.919189</td>\n",
       "      <td>-4.286936</td>\n",
       "      <td>-2.476869</td>\n",
       "      <td>-2.850136</td>\n",
       "      <td>-0.233060</td>\n",
       "      <td>0.134687</td>\n",
       "      <td>-1.675381</td>\n",
       "      <td>-1.302113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>278</th>\n",
       "      <td>2020-02-28</td>\n",
       "      <td>-3.291569</td>\n",
       "      <td>-3.027993</td>\n",
       "      <td>-2.995196</td>\n",
       "      <td>-3.936630</td>\n",
       "      <td>-3.904141</td>\n",
       "      <td>-0.263577</td>\n",
       "      <td>-0.296373</td>\n",
       "      <td>0.645061</td>\n",
       "      <td>0.612572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>2020-03-02</td>\n",
       "      <td>2.964427</td>\n",
       "      <td>3.633032</td>\n",
       "      <td>3.550425</td>\n",
       "      <td>2.932988</td>\n",
       "      <td>2.850939</td>\n",
       "      <td>-0.668605</td>\n",
       "      <td>-0.585998</td>\n",
       "      <td>0.031439</td>\n",
       "      <td>0.113488</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>280</th>\n",
       "      <td>2020-03-03</td>\n",
       "      <td>0.309234</td>\n",
       "      <td>-0.041469</td>\n",
       "      <td>0.397138</td>\n",
       "      <td>0.034011</td>\n",
       "      <td>0.472950</td>\n",
       "      <td>0.350703</td>\n",
       "      <td>-0.087904</td>\n",
       "      <td>0.275223</td>\n",
       "      <td>-0.163715</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>2020-03-04</td>\n",
       "      <td>0.212608</td>\n",
       "      <td>-0.466318</td>\n",
       "      <td>-0.975291</td>\n",
       "      <td>-0.945985</td>\n",
       "      <td>-1.452505</td>\n",
       "      <td>0.678926</td>\n",
       "      <td>1.187899</td>\n",
       "      <td>1.158593</td>\n",
       "      <td>1.665113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>282</th>\n",
       "      <td>2020-03-05</td>\n",
       "      <td>-1.665429</td>\n",
       "      <td>-1.922691</td>\n",
       "      <td>-1.608400</td>\n",
       "      <td>-1.934909</td>\n",
       "      <td>-1.620656</td>\n",
       "      <td>0.257262</td>\n",
       "      <td>-0.057029</td>\n",
       "      <td>0.269480</td>\n",
       "      <td>-0.044773</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          date      real  fund_est  fund_est_2111    bc_est  bc_est_2111  \\\n",
       "263 2020-02-07 -0.647948 -0.785591      -0.037261 -1.254779    -0.509988   \n",
       "264 2020-02-10 -1.096838 -1.426025      -1.800490 -1.428398    -1.802854   \n",
       "265 2020-02-11  0.429613  0.624201       0.310294  0.932186     0.617319   \n",
       "266 2020-02-12  1.571827  2.244064       2.593395  2.198130     2.547303   \n",
       "267 2020-02-13  0.333007  0.504982       0.481938  0.701662     0.678573   \n",
       "268 2020-02-14  0.829754  1.198974       1.258412  1.343349     1.402872   \n",
       "269 2020-02-17  0.116178 -0.021618      -0.033048  0.298117     0.286651   \n",
       "270 2020-02-18 -0.232086 -0.002015       0.181235 -0.058525     0.124622   \n",
       "271 2020-02-19  2.268101  2.533318       2.275533  2.364867     2.107506   \n",
       "272 2020-02-20  0.710833  0.478790       0.813269  0.618737     0.953681   \n",
       "273 2020-02-21 -1.138716 -1.355870      -1.555549 -0.612975    -0.814157   \n",
       "274 2020-02-24 -2.760590 -3.476302      -3.494192 -3.202966    -3.220907   \n",
       "275 2020-02-25 -2.085169 -1.550823      -1.753927 -2.434255    -2.635537   \n",
       "276 2020-02-26 -1.759648 -1.753248      -1.478477 -2.359271    -2.086195   \n",
       "277 2020-02-27 -4.152249 -3.919189      -4.286936 -2.476869    -2.850136   \n",
       "278 2020-02-28 -3.291569 -3.027993      -2.995196 -3.936630    -3.904141   \n",
       "279 2020-03-02  2.964427  3.633032       3.550425  2.932988     2.850939   \n",
       "280 2020-03-03  0.309234 -0.041469       0.397138  0.034011     0.472950   \n",
       "281 2020-03-04  0.212608 -0.466318      -0.975291 -0.945985    -1.452505   \n",
       "282 2020-03-05 -1.665429 -1.922691      -1.608400 -1.934909    -1.620656   \n",
       "\n",
       "     diff_real_fund_est  diff_real_fund_est_2111  diff_real_bc_est  \\\n",
       "263            0.137642                -0.610687          0.606830   \n",
       "264            0.329187                 0.703652          0.331560   \n",
       "265           -0.194587                 0.119319         -0.502573   \n",
       "266           -0.672238                -1.021568         -0.626303   \n",
       "267           -0.171975                -0.148931         -0.368655   \n",
       "268           -0.369220                -0.428658         -0.513595   \n",
       "269            0.137796                 0.149225         -0.181939   \n",
       "270           -0.230071                -0.413321         -0.173561   \n",
       "271           -0.265216                -0.007432         -0.096765   \n",
       "272            0.232043                -0.102436          0.092097   \n",
       "273            0.217154                 0.416833         -0.525741   \n",
       "274            0.715711                 0.733602          0.442376   \n",
       "275           -0.534346                -0.331241          0.349086   \n",
       "276           -0.006400                -0.281171          0.599623   \n",
       "277           -0.233060                 0.134687         -1.675381   \n",
       "278           -0.263577                -0.296373          0.645061   \n",
       "279           -0.668605                -0.585998          0.031439   \n",
       "280            0.350703                -0.087904          0.275223   \n",
       "281            0.678926                 1.187899          1.158593   \n",
       "282            0.257262                -0.057029          0.269480   \n",
       "\n",
       "     diff_real_bc_est_2111  \n",
       "263              -0.137960  \n",
       "264               0.706016  \n",
       "265              -0.187706  \n",
       "266              -0.975477  \n",
       "267              -0.345566  \n",
       "268              -0.573118  \n",
       "269              -0.170473  \n",
       "270              -0.356708  \n",
       "271               0.160596  \n",
       "272              -0.242848  \n",
       "273              -0.324559  \n",
       "274               0.460317  \n",
       "275               0.550368  \n",
       "276               0.326547  \n",
       "277              -1.302113  \n",
       "278               0.612572  \n",
       "279               0.113488  \n",
       "280              -0.163715  \n",
       "281               1.665113  \n",
       "282              -0.044773  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nfyydf.iloc[-20:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.13494830952722817,\n",
       " 0.2729164993400751,\n",
       " 0.422895067226587,\n",
       " 0.4503039730692361)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    np.mean(np.abs(nfyydf[\"diff_real_fund_est\"][-100:])),\n",
    "    np.mean(np.abs(nfyydf[\"diff_real_fund_est_2111\"][-100:])),\n",
    "    np.mean(np.abs(nfyydf[\"diff_real_bc_est\"][-100:])),\n",
    "    np.mean(np.abs(nfyydf[\"diff_real_bc_est_2111\"][-100:])),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看出，人民币中间价做汇率换算，比人民币市场价格要准很多，利用基金持仓的涨跌直接估算，也要比用基准准很多。\n",
    "南方原油大家一直抱怨不好估值，但我想 0.13 个百分点的平均误差水平应该是全网最准了。因为我想不到比直接从持仓开始算更准的方式了。\n",
    "如果有方式用最近100交易日的数据可以打败这一偏移水平，欢迎告诉我。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11c2477b8>"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAELCAYAAADX3k30AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl83XWd7/HX55zs+9o2bdKmpYXS\nCm2hYAEXVBhBGXBDUEcW9YHjdRnvjDN3HO91mzujjo5eFZfholcYBBd0FBHHQQQBtS1taQttKN1o\nmzZt0mbfc8753D/OSQ0haU6SsyQn7+fjcR45y+/8fp/8krzzO9/f9/f9mrsjIiKZK5DuAkREJLkU\n9CIiGU5BLyKS4RT0IiIZTkEvIpLhFPQiIhlOQS8ikuEU9CIiGU5BLyKS4bLSteGqqiqvr69P1+ZF\nRGalrVu3nnT36sm8J21BX19fz5YtW9K1eRGRWcnMDk32PWq6ERHJcAp6EZEMp6AXEclwCnoRkQyn\noBcRyXAKehGRDKegFxHJcAp6EZEMp6AXEclwabsyVkT+5N5Nh8d97Z0vX5zCSiQT6YheRCTDKehF\nRDLchEFvZnlmttnMdpjZLjP7zBjL3GJmLWa2PXZ7X3LKFRGRyYqnjX4AeK27d5tZNvCkmf3K3TeO\nWu6H7v6hxJcokhnO1A4vkkwTBr27O9Ade5gdu3kyixIRkcSJq43ezIJmth1oBh52901jL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FfiKuz9pZouBXwPnAh8DPujuvzezIqCf6CQuH3P3a+L4PmSOU9BL\nqrwS+A937wWwxE0Z+OMRTTt/BlxrZh+LPc4DFgPHgNvNbC0QBs5O0LZHesTdOwDMbDewBKgCHnP3\nltjzP5xg21cAq0b8QymJBfvvgS+b2feBn7p7Y+bPSSKJpKCX2a5nxH0D3uqjZvoys08THWhuDdHm\nyv4pbivEn5o780a9NjDifpip/W0FgA3uPrq+z5vZL4kOAPZ7M3v9FNYtc5ja6CVVHgfeFOtNUwz8\neRK28WvgwxY73DWzdbHnS4Emd48A7waCU1z/C0SbYSA6lPBENgGvNrNKM8sGrp9g+f8CPjz8IPYJ\nBDM7y92fcfcvEB3adyXQBRRPrnyZqxT0khLuvg34IdHhZn9FNLAS7R+BbGCnme2KPQb4JnCzme0g\nGpI947x/Il8CPmBmTxNtljkjj44T/mngj0SbXyYaS/0jwPpYd87dRIenBfiomT1rZjuJDl/7K2An\nEDazHToZKxPRMMUiIhlOR/QiIhlOJ2NlxjOzT/DS9u0fu/s/JWj9rwe+MOrpg+7+5kSsf4ztJfX7\nERlNTTciIhlOTTciIhlOQS8ikuEU9CIiGU5BLyKS4RT0IiIZ7v8DKY/7MjGVzFcAAAAASUVORK5C\nYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11a191a90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "% matplotlib inline\n",
    "sns.distplot(nfyydf[\"diff_real_fund_est\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.05"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len([i for i in nfyydf[\"diff_real_fund_est\"][-100:] if abs(i) > 0.5]) / 100"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看出有大约5%的概率，预测净值和真实净值的偏差超过0.5个百分点，总体上是一个可以接受的净值预测\n",
    "可以和其他qdii基金比一下预测精度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "271 12 0.04240282685512368\n"
     ]
    }
   ],
   "source": [
    "# 反向预测的比例\n",
    "p = 0\n",
    "n = 0\n",
    "for i, row in nfyydf.iterrows():\n",
    "    r = row[\"fund_est\"] * row[\"real\"]\n",
    "    if r >= 0:\n",
    "        p += 1\n",
    "    else:\n",
    "        n += 1\n",
    "print(p, n, n / (n + p))\n",
    "# 竟然有4%+的机会预测完全反号。。。。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 国泰商品净值预估"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "gtspdf = estimate_table(\n",
    "    \"20190101\",\n",
    "    \"20200305\",\n",
    "    (\"real\", \"\", {\"F160216\": 100}),\n",
    "    (\"fund_est\", \"USD/CNY\", holdings_160216_19s4),\n",
    "    (\"fund_est_2111\", \"2111\", holdings_160216_19s4),\n",
    "    _default=cache_table,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>real</th>\n",
       "      <th>fund_est</th>\n",
       "      <th>fund_est_2111</th>\n",
       "      <th>diff_real_fund_est</th>\n",
       "      <th>diff_real_fund_est_2111</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>263</th>\n",
       "      <td>2020-02-07</td>\n",
       "      <td>-1.173709</td>\n",
       "      <td>-1.508188</td>\n",
       "      <td>-0.765309</td>\n",
       "      <td>0.334479</td>\n",
       "      <td>-0.408400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>264</th>\n",
       "      <td>2020-02-10</td>\n",
       "      <td>-1.425178</td>\n",
       "      <td>-1.450684</td>\n",
       "      <td>-1.825055</td>\n",
       "      <td>0.025506</td>\n",
       "      <td>0.399877</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>265</th>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>0.963855</td>\n",
       "      <td>0.941957</td>\n",
       "      <td>0.627059</td>\n",
       "      <td>0.021899</td>\n",
       "      <td>0.336796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>2.147971</td>\n",
       "      <td>2.610018</td>\n",
       "      <td>2.960598</td>\n",
       "      <td>-0.462046</td>\n",
       "      <td>-0.812627</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>0.233645</td>\n",
       "      <td>0.378472</td>\n",
       "      <td>0.355457</td>\n",
       "      <td>-0.144827</td>\n",
       "      <td>-0.121812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>1.165501</td>\n",
       "      <td>1.056623</td>\n",
       "      <td>1.115977</td>\n",
       "      <td>0.108878</td>\n",
       "      <td>0.049524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>-0.230415</td>\n",
       "      <td>-0.068726</td>\n",
       "      <td>-0.080150</td>\n",
       "      <td>-0.161689</td>\n",
       "      <td>-0.150265</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>2020-02-18</td>\n",
       "      <td>0.230947</td>\n",
       "      <td>0.149082</td>\n",
       "      <td>0.332609</td>\n",
       "      <td>0.081865</td>\n",
       "      <td>-0.101663</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>271</th>\n",
       "      <td>2020-02-19</td>\n",
       "      <td>2.304147</td>\n",
       "      <td>2.297944</td>\n",
       "      <td>2.040751</td>\n",
       "      <td>0.006204</td>\n",
       "      <td>0.263396</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>272</th>\n",
       "      <td>2020-02-20</td>\n",
       "      <td>0.675676</td>\n",
       "      <td>0.739045</td>\n",
       "      <td>1.074390</td>\n",
       "      <td>-0.063369</td>\n",
       "      <td>-0.398714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>273</th>\n",
       "      <td>2020-02-21</td>\n",
       "      <td>-0.894855</td>\n",
       "      <td>-0.966361</td>\n",
       "      <td>-1.166828</td>\n",
       "      <td>0.071506</td>\n",
       "      <td>0.271973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>274</th>\n",
       "      <td>2020-02-24</td>\n",
       "      <td>-3.611738</td>\n",
       "      <td>-3.480442</td>\n",
       "      <td>-3.498332</td>\n",
       "      <td>-0.131296</td>\n",
       "      <td>-0.113406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>275</th>\n",
       "      <td>2020-02-25</td>\n",
       "      <td>-3.044496</td>\n",
       "      <td>-3.001084</td>\n",
       "      <td>-3.201197</td>\n",
       "      <td>-0.043412</td>\n",
       "      <td>0.156700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>2020-02-26</td>\n",
       "      <td>-1.932367</td>\n",
       "      <td>-2.232813</td>\n",
       "      <td>-1.959383</td>\n",
       "      <td>0.300446</td>\n",
       "      <td>0.027016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>277</th>\n",
       "      <td>2020-02-27</td>\n",
       "      <td>-3.448276</td>\n",
       "      <td>-3.543438</td>\n",
       "      <td>-3.912623</td>\n",
       "      <td>0.095162</td>\n",
       "      <td>0.464347</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>278</th>\n",
       "      <td>2020-02-28</td>\n",
       "      <td>-3.061224</td>\n",
       "      <td>-3.473936</td>\n",
       "      <td>-3.441291</td>\n",
       "      <td>0.412712</td>\n",
       "      <td>0.380066</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>2020-03-02</td>\n",
       "      <td>3.684211</td>\n",
       "      <td>4.259999</td>\n",
       "      <td>4.176892</td>\n",
       "      <td>-0.575789</td>\n",
       "      <td>-0.492682</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>280</th>\n",
       "      <td>2020-03-03</td>\n",
       "      <td>-0.761421</td>\n",
       "      <td>-0.858441</td>\n",
       "      <td>-0.423418</td>\n",
       "      <td>0.097020</td>\n",
       "      <td>-0.338003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>2020-03-04</td>\n",
       "      <td>-0.255754</td>\n",
       "      <td>-0.283699</td>\n",
       "      <td>-0.793606</td>\n",
       "      <td>0.027944</td>\n",
       "      <td>0.537851</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>282</th>\n",
       "      <td>2020-03-05</td>\n",
       "      <td>-2.564103</td>\n",
       "      <td>-2.663462</td>\n",
       "      <td>-2.351544</td>\n",
       "      <td>0.099360</td>\n",
       "      <td>-0.212558</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          date      real  fund_est  fund_est_2111  diff_real_fund_est  \\\n",
       "263 2020-02-07 -1.173709 -1.508188      -0.765309            0.334479   \n",
       "264 2020-02-10 -1.425178 -1.450684      -1.825055            0.025506   \n",
       "265 2020-02-11  0.963855  0.941957       0.627059            0.021899   \n",
       "266 2020-02-12  2.147971  2.610018       2.960598           -0.462046   \n",
       "267 2020-02-13  0.233645  0.378472       0.355457           -0.144827   \n",
       "268 2020-02-14  1.165501  1.056623       1.115977            0.108878   \n",
       "269 2020-02-17 -0.230415 -0.068726      -0.080150           -0.161689   \n",
       "270 2020-02-18  0.230947  0.149082       0.332609            0.081865   \n",
       "271 2020-02-19  2.304147  2.297944       2.040751            0.006204   \n",
       "272 2020-02-20  0.675676  0.739045       1.074390           -0.063369   \n",
       "273 2020-02-21 -0.894855 -0.966361      -1.166828            0.071506   \n",
       "274 2020-02-24 -3.611738 -3.480442      -3.498332           -0.131296   \n",
       "275 2020-02-25 -3.044496 -3.001084      -3.201197           -0.043412   \n",
       "276 2020-02-26 -1.932367 -2.232813      -1.959383            0.300446   \n",
       "277 2020-02-27 -3.448276 -3.543438      -3.912623            0.095162   \n",
       "278 2020-02-28 -3.061224 -3.473936      -3.441291            0.412712   \n",
       "279 2020-03-02  3.684211  4.259999       4.176892           -0.575789   \n",
       "280 2020-03-03 -0.761421 -0.858441      -0.423418            0.097020   \n",
       "281 2020-03-04 -0.255754 -0.283699      -0.793606            0.027944   \n",
       "282 2020-03-05 -2.564103 -2.663462      -2.351544            0.099360   \n",
       "\n",
       "     diff_real_fund_est_2111  \n",
       "263                -0.408400  \n",
       "264                 0.399877  \n",
       "265                 0.336796  \n",
       "266                -0.812627  \n",
       "267                -0.121812  \n",
       "268                 0.049524  \n",
       "269                -0.150265  \n",
       "270                -0.101663  \n",
       "271                 0.263396  \n",
       "272                -0.398714  \n",
       "273                 0.271973  \n",
       "274                -0.113406  \n",
       "275                 0.156700  \n",
       "276                 0.027016  \n",
       "277                 0.464347  \n",
       "278                 0.380066  \n",
       "279                -0.492682  \n",
       "280                -0.338003  \n",
       "281                 0.537851  \n",
       "282                -0.212558  "
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gtspdf.iloc[-20:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.10589187603833962, 0.22399439609501928)"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    np.mean(np.abs(gtspdf[\"diff_real_fund_est\"][-100:])),\n",
    "    np.mean(np.abs(gtspdf[\"diff_real_fund_est_2111\"][-100:])),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.02266683846031749, -0.023893072096493828, 0.007916101144943788)"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 看看有没有肉眼可见的系统偏差\n",
    "(\n",
    "    np.mean(gtspdf[\"diff_real_fund_est\"][-150:-100]),\n",
    "    np.mean(gtspdf[\"diff_real_fund_est\"][-100:-50]),\n",
    "    np.mean(gtspdf[\"diff_real_fund_est\"][-50:]),\n",
    ")\n",
    "# 最近的最准，也可以理解，毕竟是按照4季度底持仓模拟的"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "预测精度要比南方原油好，用人民币中间价，平均误差只有0.1个百分点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1131cf4a8>"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAELCAYAAAAiIMZEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmY3FWd7/H3t5be9z3pNf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bvh34F0icpBgYRxb5O+H80XgAyKyn+CQy5I0uJ3gZ4A/Ehxa\nORbmr3wE2Bk69fIo8P7Q8x8VkSMicojgUsi/IbjstF9EDtqEqlmILflrjDEpyHruxhiTgmxC1SQ8\nEfkkLx2v/qmq/mOUjv8q4PPznj6lqv8tGsdf4P1i+u8xBmxYxhhjUpINyxhjTAqy4m6MMSnIirsx\nxqQgK+7GGJOCrLgbY0wK+v8cHPdFzjgtYAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11c24efd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(gtspdf[\"diff_real_fund_est\"])  # 看误差分布展宽也明显比南方原油窄"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.05"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len([i for i in gtspdf[\"diff_real_fund_est\"][-100:] if abs(i) > 0.31]) / 100"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "极端值情况，5%分位的误差偏移仅有0.31个百分点，也比南方原油强不少，因此国泰商品预测性更强，更适合套利，或者说套利溢价的阈值更低，因为溢价预测的误差窗口小一些。\n",
    "\n",
    "我们再看一下，预测误差的正负和实际上涨与下降之间的关系，这之前先看一下完全反号的预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "283 0 0.0\n"
     ]
    }
   ],
   "source": [
    "p = 0\n",
    "n = 0\n",
    "for i, row in gtspdf.iterrows():\n",
    "    r = row[\"fund_est\"] * row[\"real\"]\n",
    "    if r >= 0:\n",
    "        p += 1\n",
    "    else:\n",
    "        n += 1\n",
    "print(p, n, n / (n + p))\n",
    "# 并没有反向预测这种严重错误，这是一个好消息！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "65 99 63 56\n"
     ]
    }
   ],
   "source": [
    "uu, ud, dd, du = 0, 0, 0, 0\n",
    "# uu 实际上涨，real-est>0 (预测涨的少)\n",
    "# ud 预测涨的多\n",
    "# du 预测跌的多\n",
    "# dd 预测跌的少\n",
    "for i, row in gtspdf.iterrows():\n",
    "    if row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        uu += 1\n",
    "    elif row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] <= 0:\n",
    "        ud += 1\n",
    "    elif row[\"real\"] < 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        du += 1\n",
    "    else:\n",
    "        dd += 1\n",
    "print(uu, ud, du, dd)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "还是比较平均的，预测涨的比实际多的情况稍多。也就是说预计涨的时候，可能预计的偏大。预计跌的时候，还是没有什么系统性误差的。\n",
    "\n",
    "说人话就是基金涨的时候跟不上持仓，跌的时候跟挺紧。。。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 华宝油气净值预估情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "hbyqdf = estimate_table(\n",
    "    \"20190101\",\n",
    "    \"20200305\",\n",
    "    (\"real\", \"\", {\"F162411\": 100}),\n",
    "    (\"fund_est\", \"USD/CNY\", holdings_162411_19s4),\n",
    "    (\"fund_est_2111\", \"2111\", holdings_162411_19s4),\n",
    "    _default=cache_table,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>real</th>\n",
       "      <th>fund_est</th>\n",
       "      <th>fund_est_2111</th>\n",
       "      <th>diff_real_fund_est</th>\n",
       "      <th>diff_real_fund_est_2111</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>263</th>\n",
       "      <td>2020-02-07</td>\n",
       "      <td>-1.873199</td>\n",
       "      <td>-1.913981</td>\n",
       "      <td>-1.174162</td>\n",
       "      <td>0.040782</td>\n",
       "      <td>-0.699037</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>264</th>\n",
       "      <td>2020-02-10</td>\n",
       "      <td>-2.055800</td>\n",
       "      <td>-2.121451</td>\n",
       "      <td>-2.493273</td>\n",
       "      <td>0.065650</td>\n",
       "      <td>0.437473</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>265</th>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>0.539730</td>\n",
       "      <td>0.578453</td>\n",
       "      <td>0.264689</td>\n",
       "      <td>-0.038723</td>\n",
       "      <td>0.275041</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>0.745601</td>\n",
       "      <td>0.792262</td>\n",
       "      <td>1.136632</td>\n",
       "      <td>-0.046661</td>\n",
       "      <td>-0.391031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>-0.266430</td>\n",
       "      <td>-0.265953</td>\n",
       "      <td>-0.288820</td>\n",
       "      <td>-0.000477</td>\n",
       "      <td>0.022391</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>-0.831107</td>\n",
       "      <td>-0.931193</td>\n",
       "      <td>-0.873006</td>\n",
       "      <td>0.100086</td>\n",
       "      <td>0.041899</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>-0.089793</td>\n",
       "      <td>-0.068726</td>\n",
       "      <td>-0.080150</td>\n",
       "      <td>-0.021068</td>\n",
       "      <td>-0.009643</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>2020-02-18</td>\n",
       "      <td>-0.629119</td>\n",
       "      <td>-0.674867</td>\n",
       "      <td>-0.492850</td>\n",
       "      <td>0.045748</td>\n",
       "      <td>-0.136270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>271</th>\n",
       "      <td>2020-02-19</td>\n",
       "      <td>2.653000</td>\n",
       "      <td>2.920169</td>\n",
       "      <td>2.661412</td>\n",
       "      <td>-0.267169</td>\n",
       "      <td>-0.008412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>272</th>\n",
       "      <td>2020-02-20</td>\n",
       "      <td>0.205580</td>\n",
       "      <td>0.234215</td>\n",
       "      <td>0.567880</td>\n",
       "      <td>-0.028635</td>\n",
       "      <td>-0.362300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>273</th>\n",
       "      <td>2020-02-21</td>\n",
       "      <td>-1.524033</td>\n",
       "      <td>-1.646148</td>\n",
       "      <td>-1.845239</td>\n",
       "      <td>0.122115</td>\n",
       "      <td>0.321206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>274</th>\n",
       "      <td>2020-02-24</td>\n",
       "      <td>-5.089286</td>\n",
       "      <td>-5.531251</td>\n",
       "      <td>-5.548761</td>\n",
       "      <td>0.441965</td>\n",
       "      <td>0.459475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>275</th>\n",
       "      <td>2020-02-25</td>\n",
       "      <td>-4.358733</td>\n",
       "      <td>-4.790551</td>\n",
       "      <td>-4.986971</td>\n",
       "      <td>0.431817</td>\n",
       "      <td>0.628238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>2020-02-26</td>\n",
       "      <td>-4.098361</td>\n",
       "      <td>-4.569926</td>\n",
       "      <td>-4.303033</td>\n",
       "      <td>0.471565</td>\n",
       "      <td>0.204672</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>277</th>\n",
       "      <td>2020-02-27</td>\n",
       "      <td>-5.094017</td>\n",
       "      <td>-5.641765</td>\n",
       "      <td>-6.002919</td>\n",
       "      <td>0.547748</td>\n",
       "      <td>0.908902</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>278</th>\n",
       "      <td>2020-02-28</td>\n",
       "      <td>2.737752</td>\n",
       "      <td>3.068003</td>\n",
       "      <td>3.102861</td>\n",
       "      <td>-0.330251</td>\n",
       "      <td>-0.365109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>2020-03-02</td>\n",
       "      <td>-0.736325</td>\n",
       "      <td>-0.848291</td>\n",
       "      <td>-0.927326</td>\n",
       "      <td>0.111965</td>\n",
       "      <td>0.191001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>280</th>\n",
       "      <td>2020-03-03</td>\n",
       "      <td>-2.825857</td>\n",
       "      <td>-3.158663</td>\n",
       "      <td>-2.733733</td>\n",
       "      <td>0.332806</td>\n",
       "      <td>-0.092123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>2020-03-04</td>\n",
       "      <td>0.399855</td>\n",
       "      <td>0.450548</td>\n",
       "      <td>-0.063114</td>\n",
       "      <td>-0.050693</td>\n",
       "      <td>0.462968</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>282</th>\n",
       "      <td>2020-03-05</td>\n",
       "      <td>-3.511948</td>\n",
       "      <td>-3.924178</td>\n",
       "      <td>-3.616300</td>\n",
       "      <td>0.412230</td>\n",
       "      <td>0.104352</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          date      real  fund_est  fund_est_2111  diff_real_fund_est  \\\n",
       "263 2020-02-07 -1.873199 -1.913981      -1.174162            0.040782   \n",
       "264 2020-02-10 -2.055800 -2.121451      -2.493273            0.065650   \n",
       "265 2020-02-11  0.539730  0.578453       0.264689           -0.038723   \n",
       "266 2020-02-12  0.745601  0.792262       1.136632           -0.046661   \n",
       "267 2020-02-13 -0.266430 -0.265953      -0.288820           -0.000477   \n",
       "268 2020-02-14 -0.831107 -0.931193      -0.873006            0.100086   \n",
       "269 2020-02-17 -0.089793 -0.068726      -0.080150           -0.021068   \n",
       "270 2020-02-18 -0.629119 -0.674867      -0.492850            0.045748   \n",
       "271 2020-02-19  2.653000  2.920169       2.661412           -0.267169   \n",
       "272 2020-02-20  0.205580  0.234215       0.567880           -0.028635   \n",
       "273 2020-02-21 -1.524033 -1.646148      -1.845239            0.122115   \n",
       "274 2020-02-24 -5.089286 -5.531251      -5.548761            0.441965   \n",
       "275 2020-02-25 -4.358733 -4.790551      -4.986971            0.431817   \n",
       "276 2020-02-26 -4.098361 -4.569926      -4.303033            0.471565   \n",
       "277 2020-02-27 -5.094017 -5.641765      -6.002919            0.547748   \n",
       "278 2020-02-28  2.737752  3.068003       3.102861           -0.330251   \n",
       "279 2020-03-02 -0.736325 -0.848291      -0.927326            0.111965   \n",
       "280 2020-03-03 -2.825857 -3.158663      -2.733733            0.332806   \n",
       "281 2020-03-04  0.399855  0.450548      -0.063114           -0.050693   \n",
       "282 2020-03-05 -3.511948 -3.924178      -3.616300            0.412230   \n",
       "\n",
       "     diff_real_fund_est_2111  \n",
       "263                -0.699037  \n",
       "264                 0.437473  \n",
       "265                 0.275041  \n",
       "266                -0.391031  \n",
       "267                 0.022391  \n",
       "268                 0.041899  \n",
       "269                -0.009643  \n",
       "270                -0.136270  \n",
       "271                -0.008412  \n",
       "272                -0.362300  \n",
       "273                 0.321206  \n",
       "274                 0.459475  \n",
       "275                 0.628238  \n",
       "276                 0.204672  \n",
       "277                 0.908902  \n",
       "278                -0.365109  \n",
       "279                 0.191001  \n",
       "280                -0.092123  \n",
       "281                 0.462968  \n",
       "282                 0.104352  "
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hbyqdf.iloc[-20:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这个净值预估就有点意思了，因为雪球上油气姐也有每日官方的净值预报，让我们比一下谁的更准\n",
    "要知道实在不行我们还有个持仓比例的超参可以调！\n",
    "\n",
    "下面是雪球的预估数据\n",
    "3.5 -4.06\n",
    "3.4 0.33\n",
    "3.3 -3.21\n",
    "3.2 -0.77\n",
    "2.28 3.39\n",
    "\n",
    "就拿最新五天的数据为例，四天都是我们上面的预计更准，因此可以说也是全网最准了，毕竟比官方的预估要接近真实值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.11470246307431636, 0.25056930156434193)"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    np.mean(np.abs(hbyqdf[\"diff_real_fund_est\"][-200:])),\n",
    "    np.mean(np.abs(hbyqdf[\"diff_real_fund_est_2111\"][-200:])),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "油气的预测平均偏差是0.11个百分点强，比国泰商品的预测精度还低，同样是人民币中间价比市价准很多。\n",
    "这样看国泰商品竟然是比华宝油气这种跟踪单一指数的产品净值预测更容易，估计这颠覆了很多人的认识"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.03564024234015609, -0.009798129247228005, 0.02813788155226706)"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    np.mean(hbyqdf[\"diff_real_fund_est\"][-150:-100]),\n",
    "    np.mean(hbyqdf[\"diff_real_fund_est\"][-100:-50]),\n",
    "    np.mean(hbyqdf[\"diff_real_fund_est\"][-50:]),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11ce162e8>"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAELCAYAAAAiIMZEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmcnHWV7/HP6X3fO72ll+wkkJUm\nYRGDLIqAoIKKyAygDoPKVUfnXr06wyjzckaYGec6giKuIDuoGBbZl0Ag+0b2dLbuTjq973tVnftH\nVaDT6aSqO1X1VFWf9+tVr9TyVNW3O92nn/o9v+f8RFUxxhgTW+KcDmCMMSb4rLgbY0wMsuJujDEx\nyIq7McbEICvuxhgTg6y4G2NMDLLibowxMciKuzHGxCAr7sYYE4MSnHrjgoICraqqcurtjTEmKm3Y\nsKFFVQv9bedYca+qqmL9+vVOvb0xxkQlETkUyHZ+h2VEJEVE1orIFhHZLiI/HGObm0WkWUQ2+y5f\nnkhoY4wxwRHInvsgcLGq9ohIIvC2iPxVVVeP2u5xVb09+BGNMcaMl9/irt62kT2+m4m+i7WSNMaY\nCBbQbBkRiReRzUAT8LKqrhljs2tFZKuIPCUi5UFNaYwxZlwCKu6q6lbVRcBUYKmInDVqk2eAKlVd\nALwMPDD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NixjjDExyYZljDEmBllxN8aYGGTF3RhjYpAV\nd2OMiUFW3I0xJgb9f+erI0xemPoFAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11d1ed4e0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(hbyqdf[\"diff_real_fund_est\"], bins=40)  # 误差分布涨的有点丑, 好像确实也没有国泰商品的正态"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.05"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len([i for i in hbyqdf[\"diff_real_fund_est\"][-100:] if abs(i) > 0.40]) / 100"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "百分之五极端分位是预测偏离0.4个百分点"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "283 0 0.0\n"
     ]
    }
   ],
   "source": [
    "p = 0\n",
    "n = 0\n",
    "for i, row in hbyqdf.iterrows():\n",
    "    r = row[\"fund_est\"] * row[\"real\"]\n",
    "    if r >= 0:\n",
    "        p += 1\n",
    "    else:\n",
    "        n += 1\n",
    "print(p, n, n / (n + p))\n",
    "# 无反相预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "78 67 58 80\n"
     ]
    }
   ],
   "source": [
    "uu, ud, dd, du = 0, 0, 0, 0\n",
    "# uu 实际上涨，real-est>0 (预测涨的少)\n",
    "# ud 预测涨的多\n",
    "# du 预测跌的多\n",
    "# dd 预测跌的少\n",
    "for i, row in hbyqdf.iterrows():\n",
    "    if row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        uu += 1\n",
    "    elif row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] <= 0:\n",
    "        ud += 1\n",
    "    elif row[\"real\"] < 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        du += 1\n",
    "    else:\n",
    "        dd += 1\n",
    "print(uu, ud, du, dd)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "对于华宝油气，预估涨的时候往往预估得不如真实涨的多；预估跌的时候，往往预估比实际跌的少，这似乎说明华宝油气预估的仓位不足，导致预估倾向比较小，让我们调一下这个超参"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "hbyqdf91 = estimate_table(\n",
    "    \"20190101\",\n",
    "    \"20200305\",\n",
    "    (\"real\", \"\", {\"F162411\": 100}),\n",
    "    (\"fund_est\", \"USD/CNY\", {\"1010825\": 91}),\n",
    "    (\"fund_est_2111\", \"2111\", {\"1010825\": 91}),\n",
    "    _default=cache_table,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "72 73 62 76\n"
     ]
    }
   ],
   "source": [
    "uu, ud, dd, du = 0, 0, 0, 0\n",
    "# uu 实际上涨，real-est>0 (预测涨的少)\n",
    "# ud 预测涨的多\n",
    "# du 预测跌的多\n",
    "# dd 预测跌的少\n",
    "for i, row in hbyqdf91.iterrows():\n",
    "    if row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        uu += 1\n",
    "    elif row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] <= 0:\n",
    "        ud += 1\n",
    "    elif row[\"real\"] < 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        du += 1\n",
    "    else:\n",
    "        dd += 1\n",
    "print(uu, ud, du, dd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.11827697989010805"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.mean(np.abs(hbyqdf91[\"diff_real_fund_est\"][-200:]))  # 偏差大了点，但是预测与实际涨跌偏差的正负比较对称了\n",
    "# 所以仓位90 91 自己看着办吧，差不太多"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## DAX30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "warning: this fund has no data for rate\n"
     ]
    }
   ],
   "source": [
    "cache_data(cache_table, [\"EUR/CNY\", \"/indices/germany-30\", \"F513030\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "daxdf = estimate_table(\n",
    "    \"20190101\",\n",
    "    \"20200305\",\n",
    "    (\"real\", \"\", {\"F513030\": 100}),\n",
    "    (\"fund_est\", \"EUR/CNY\", {\"/indices/germany-30\": 97}),\n",
    "    _default=cache_table,\n",
    ")\n",
    "\n",
    "# 这里的仓位97是调超参得到的最好结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.03418095656058967"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.mean(np.abs(daxdf[\"diff_real_fund_est\"][-200:]))\n",
    "# 平均 0.03 偏移，德国30跟踪还是很可以的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>real</th>\n",
       "      <th>fund_est</th>\n",
       "      <th>diff_real_fund_est</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>263</th>\n",
       "      <td>2020-02-07</td>\n",
       "      <td>-0.884956</td>\n",
       "      <td>-0.878367</td>\n",
       "      <td>-0.006589</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>264</th>\n",
       "      <td>2020-02-10</td>\n",
       "      <td>-0.267857</td>\n",
       "      <td>-0.259268</td>\n",
       "      <td>-0.008590</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>265</th>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>0.626679</td>\n",
       "      <td>0.580633</td>\n",
       "      <td>0.046046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>0.711744</td>\n",
       "      <td>0.693314</td>\n",
       "      <td>0.018430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>-0.353357</td>\n",
       "      <td>-0.357733</td>\n",
       "      <td>0.004376</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>-0.265957</td>\n",
       "      <td>-0.228721</td>\n",
       "      <td>-0.037236</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>0.177778</td>\n",
       "      <td>0.216454</td>\n",
       "      <td>-0.038676</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>2020-02-18</td>\n",
       "      <td>-0.709849</td>\n",
       "      <td>-0.725345</td>\n",
       "      <td>0.015496</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>271</th>\n",
       "      <td>2020-02-19</td>\n",
       "      <td>0.714924</td>\n",
       "      <td>0.663141</td>\n",
       "      <td>0.051783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>272</th>\n",
       "      <td>2020-02-20</td>\n",
       "      <td>-0.798580</td>\n",
       "      <td>-0.712748</td>\n",
       "      <td>-0.085832</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>273</th>\n",
       "      <td>2020-02-21</td>\n",
       "      <td>-0.536673</td>\n",
       "      <td>-0.541978</td>\n",
       "      <td>0.005306</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>274</th>\n",
       "      <td>2020-02-24</td>\n",
       "      <td>-3.507194</td>\n",
       "      <td>-3.424654</td>\n",
       "      <td>-0.082540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>275</th>\n",
       "      <td>2020-02-25</td>\n",
       "      <td>-1.770736</td>\n",
       "      <td>-1.696144</td>\n",
       "      <td>-0.074593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>2020-02-26</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.030565</td>\n",
       "      <td>0.030565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>277</th>\n",
       "      <td>2020-02-27</td>\n",
       "      <td>-2.941176</td>\n",
       "      <td>-2.913132</td>\n",
       "      <td>-0.028044</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>278</th>\n",
       "      <td>2020-02-28</td>\n",
       "      <td>-3.030303</td>\n",
       "      <td>-2.928281</td>\n",
       "      <td>-0.102022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>279</th>\n",
       "      <td>2020-03-02</td>\n",
       "      <td>-0.100806</td>\n",
       "      <td>-0.064356</td>\n",
       "      <td>-0.036450</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>280</th>\n",
       "      <td>2020-03-03</td>\n",
       "      <td>1.412714</td>\n",
       "      <td>1.361134</td>\n",
       "      <td>0.051580</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>2020-03-04</td>\n",
       "      <td>1.393035</td>\n",
       "      <td>1.425901</td>\n",
       "      <td>-0.032866</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>282</th>\n",
       "      <td>2020-03-05</td>\n",
       "      <td>-1.962709</td>\n",
       "      <td>-1.970918</td>\n",
       "      <td>0.008209</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          date      real  fund_est  diff_real_fund_est\n",
       "263 2020-02-07 -0.884956 -0.878367           -0.006589\n",
       "264 2020-02-10 -0.267857 -0.259268           -0.008590\n",
       "265 2020-02-11  0.626679  0.580633            0.046046\n",
       "266 2020-02-12  0.711744  0.693314            0.018430\n",
       "267 2020-02-13 -0.353357 -0.357733            0.004376\n",
       "268 2020-02-14 -0.265957 -0.228721           -0.037236\n",
       "269 2020-02-17  0.177778  0.216454           -0.038676\n",
       "270 2020-02-18 -0.709849 -0.725345            0.015496\n",
       "271 2020-02-19  0.714924  0.663141            0.051783\n",
       "272 2020-02-20 -0.798580 -0.712748           -0.085832\n",
       "273 2020-02-21 -0.536673 -0.541978            0.005306\n",
       "274 2020-02-24 -3.507194 -3.424654           -0.082540\n",
       "275 2020-02-25 -1.770736 -1.696144           -0.074593\n",
       "276 2020-02-26  0.000000 -0.030565            0.030565\n",
       "277 2020-02-27 -2.941176 -2.913132           -0.028044\n",
       "278 2020-02-28 -3.030303 -2.928281           -0.102022\n",
       "279 2020-03-02 -0.100806 -0.064356           -0.036450\n",
       "280 2020-03-03  1.412714  1.361134            0.051580\n",
       "281 2020-03-04  1.393035  1.425901           -0.032866\n",
       "282 2020-03-05 -1.962709 -1.970918            0.008209"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "daxdf.iloc[-20:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.010051134143197249, -0.0079593039572593)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    np.mean(daxdf[\"diff_real_fund_est\"][-200:-100]),\n",
    "    np.mean(daxdf[\"diff_real_fund_est\"][-200:]),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "76 80 48 79\n"
     ]
    }
   ],
   "source": [
    "uu, ud, dd, du = 0, 0, 0, 0\n",
    "# uu 实际上涨，real-est>0 (预测涨的少)\n",
    "# ud 预测涨的多\n",
    "# du 预测跌的多\n",
    "# dd 预测跌的少\n",
    "for i, row in daxdf.iterrows():\n",
    "    if row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        uu += 1\n",
    "    elif row[\"real\"] >= 0 and row[\"diff_real_fund_est\"] <= 0:\n",
    "        ud += 1\n",
    "    elif row[\"real\"] < 0 and row[\"diff_real_fund_est\"] > 0:\n",
    "        du += 1\n",
    "    else:\n",
    "        dd += 1\n",
    "print(uu, ud, du, dd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x119a12780>"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAELCAYAAADJF31HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3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LgmfvZJDaN7TaHsW+HJ4eGPMbEb4/lxgt3MuSGhyjMAgl7+N0O4T+MdQxEey\nFDjNzArCQ//+01Ge/zfgy+9+Ef6LAjOb6Jxb45z7EaHhWqcSmmYwZ2DxZbhRoUtMOOdWAY8QGir0\naULFFG3fA1KA1Wa2Lvw1wK+Aa83sbUJl2HaY7z+anwCfN7M3Ce1OOSIXmhDlO8DrhHabbDjKt3wF\nqAyfJrke+Ofw/V81s7VmthroIfT6rQb6zOxtHRSVw9HwuSIiPqEtdBERn9BBUYk7ZnYzH9z//Afn\n3H9FafnnAj96393VzrlLo7H8Q6wvpj+PyLu0y0VExCe0y0VExCdU6CIiPqFCFxHxCRW6iIhPqNBF\nRHzi/wOq49UR9K6kVQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x119a1db38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "sns.distplot(daxdf[\"diff_real_fund_est\"], bins=30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
